/**
 * Created by Admin on 2017/6/8.
 */

function xxk() {
    var xxk = document.getElementById("xxk");
    var tcbc = document.getElementsByClassName("tcbc");

    for (var i = 0; i < xxk.children.length; i++) {
        xxk.children[i].index = i;
        xxk.children[i].onclick = function () {
            for (var i = 0; i < xxk.children.length; i++) {
                xxk.children[i].className = '';
                tcbc[0].children[i].style.display = 'none';
            }
            this.className = 'on';
            tcbc[0].children[this.index].style.display = 'block';
        }
    }
}
;

function ajax() {
    var list;
    $.ajax({
        async: false,
        type: 'get',
        url: '/art/load',
        dataType: 'json',
        success: function (data) {
            list = eval(data);
            for (var i = 0; i < list.length; i++) {
                addArtOnPage(list[i].userAccount, list[i].artTitle, list[i].artContext)
            }

        },
        error: function (data) {
            alert("JSON数据获取失败，请联系管理员！");
        }
    });
}
function addArtOnPage(a, b, c) {
    var str = "<div class='art'><h3><a href='##'>" + a + "</a>发布博客:<a href='#'>" + b + "</a></h3> <p>" + c + "</p> <div class='art_column'> <ul> <li><a href='../resources/login.jsp'>赞</a></li><li><a href='../resources/login.jsp'>转发</a></li> </ul> </div> </div>";
    var lyh = $('#lyh');
    lyh.append(str);
}
window.onload=function(){
    xxk();
    ajax();
}